unit fmCardInfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Mask, DB, MemDS, DBAccess, MSAccess,
  dxPSGlbl, dxPSUtl, dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPrnDev,
  dxPSCompsProvider, dxPSFillPatterns, dxPSEdgePatterns, dxPSPDFExportCore,
  dxPSPDFExport, cxDrawTextUtils, dxPSPrVwStd, dxPSPrVwAdv, dxPSPrVwRibbon,
  dxPScxEditorProducers, dxPScxExtEditorProducers,
  dxPScxPageControlProducer, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxStyles, cxCustomData, cxFilter, cxData,
  cxDataStorage, cxEdit, cxDBData, cxGridLevel, cxClasses,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxGrid, dxPSCore, cxDBLookupComboBox, dxPScxCommon,
  dxPScxGrid6Lnk;

type
  TCardInfoForm = class(TForm)
    grp1: TGroupBox;
    medtAccount: TMaskEdit;
    btnOK: TBitBtn;
    btnExport: TBitBtn;
    lbl3: TLabel;
    msqryCard: TMSQuery;
    dxComponentPrinter: TdxComponentPrinter;
    tvCard: TcxGridDBTableView;
    glCard: TcxGridLevel;
    cxGrid1: TcxGrid;
    srcCard: TDataSource;
    tvCardCARDNO: TcxGridDBColumn;
    tvCardCARDType: TcxGridDBColumn;
    tvCardAccountNo: TcxGridDBColumn;
    tvCardFREEROAD: TcxGridDBColumn;
    tvCardVehPlate: TcxGridDBColumn;
    tvCardVehClass: TcxGridDBColumn;
    tvCardBEGDT: TcxGridDBColumn;
    tvCardENDDT: TcxGridDBColumn;
    tvCardMARK: TcxGridDBColumn;
    tblFreeRoad: TMSTable;
    srcFreeRoad: TDataSource;
    tblAccount: TMSTable;
    srcAccount: TDataSource;
    tblMark: TMSTable;
    srcMark: TDataSource;
    tblcardType: TMSTable;
    srcCardType: TDataSource;
    dxComponentPrinterLink1: TdxGridReportLink;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle3: TcxStyle;
    cxStyle4: TcxStyle;
    cxStyle5: TcxStyle;
    msspGen: TMSStoredProc;
    MSQuery1: TMSQuery;
    procedure btnOKClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure btnExportClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  CardInfoForm: TCardInfoForm;

implementation

uses
  fmMain;

{$R *.dfm}

procedure TCardInfoForm.btnOKClick(Sender: TObject);
var
  vAccountNo, vSQL: string;
begin
   vAccountNo := Trim(medtAccount.Text);
   if vAccountNo = '' Then
      vSQL := 'Select * from TS_SpeCard '
   else
      vSQL := 'Select * from TS_SpeCard where AccountNo=' + vAccountNo;

   msqryCard.Close;
   msqryCard.SQL.Text := vSQL;
   msqryCard.Open;

   tvCard.DataController.Groups.FullExpand;
   
end;

procedure TCardInfoForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
   tblcardType.Close;
   tblFreeRoad.Close;
   tblAccount.Close;
   tblMark.Close;
   Action := caFree;
end;

procedure TCardInfoForm.FormCreate(Sender: TObject);
begin
   tblcardType.Open;
   tblFreeRoad.Open;
   tblAccount.Open;
   tblMark.Open;
end;

procedure TCardInfoForm.btnExportClick(Sender: TObject);
begin
   dxComponentPrinter.Preview(True);
end;

end.
